package com.cardbaobao.cardbabyclient.ui.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cardbaobao.cardbabyclient.R;
import com.cardbaobao.cardbabyclient.buried.Self;
import com.cardbaobao.cardbabyclient.ui.activity.base.BaseActivity;
import com.cardbaobao.cardbabyclient.widget.TitleBar;

import java.text.DecimalFormat;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Description: 信用卡 还款 结果页
 * Created by FHW
 * on 2017/11/15
 */

public class RepayResultActivity extends BaseActivity {

    @BindView(R.id.title_bar)
    TitleBar title_bar;


    @BindView(R.id.rl_suc)
    RelativeLayout rl_suc;
    @BindView(R.id.tv_bank_name)
    TextView tv_bank_name;
    @BindView(R.id.tv_money)
    TextView tv_money;
    @BindView(R.id.tv_state)
    TextView tv_state;
    @BindView(R.id.tv_remark1)
    TextView tv_remark1;
    @BindView(R.id.tv_remark2)
    TextView tv_remark2;

    @BindView(R.id.ll_fai)
    LinearLayout ll_fai;
    @BindView(R.id.tv_mark1)
    TextView tv_mark1;
    @BindView(R.id.tv_mark2)
    TextView tv_mark2;
    @BindView(R.id.tv_back)
    TextView tv_back;

    private String state = "";
    private String money = "";
    private String remark1 = "";
    private String remark2 = "";

    private String userName = "";
    private String bankName = "";
    private String cardNumber = "";

    private DecimalFormat df = new DecimalFormat("#0.00");

    @Override
    protected int getLayoutId() {
        return R.layout.activity_repayment_result;
    }

    @OnClick({R.id.tv_back})
    void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_back:
                finish();
                break;
        }
    }

    @Override
    protected void initView(Bundle savedInstanceState) {

        mCurrentPageId = Self.Page.app_repayment_pay_status;

        title_bar.setRightViewOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        state = getIntent().getStringExtra("state");
        remark1 = getIntent().getStringExtra("remark1");
        remark2 = getIntent().getStringExtra("remark2");

        if ("还款失败".equals(state)) {
            rl_suc.setVisibility(View.GONE);
            ll_fai.setVisibility(View.VISIBLE);

            tv_mark1.setText(remark1);
            tv_mark2.setText(remark2);

        } else {
            rl_suc.setVisibility(View.VISIBLE);
            ll_fai.setVisibility(View.GONE);
            userName = getIntent().getStringExtra("userName");
            money = getIntent().getStringExtra("money");
            bankName = getIntent().getStringExtra("bankName");
            cardNumber = getIntent().getStringExtra("cardNumber");

            tv_bank_name.setText(bankName + "（尾号" + cardNumber.substring(cardNumber.length() - 4, cardNumber.length()) + "）" + userName);
            if (!"".equals(money)) {
                tv_money.setText(df.format(Double.parseDouble(money)) + "元");
            }

//            tv_state.setText(state);
            tv_remark1.setText(remark1);
            tv_remark2.setText(remark2);
        }

    }

    @Override
    protected void initData(Bundle savedInstanceState) {
    }
}
